<template>
  <component :is="componentName" :id="rowId" @subPage="subPage"></component>
</template>
<script setup lang="ts" name="goodsSourceManage">
  import GoodsSourceList from './goodsSourceList.vue'
  import FindTrain from './findTrain.vue'
  import { useCommonStore, useCommonStoreOut } from '@/store/modules/common'

  let rowId = undefined
  const componentName = ref(GoodsSourceList)
  const pageList = [GoodsSourceList, FindTrain]
  const commonStore = useCommonStore()
  const commonStoreOut = useCommonStoreOut()

  const subPage = async (index, id) => {
    componentName.value = pageList[index]
    if (index === 0) {
      commonStoreOut.setFormData(null)
    }
  }
  onMounted(() => {
    if (commonStore.getFormData?.index) {
      subPage(commonStore.getFormData?.index)
    }
  })
</script>